package com.bg.service.impl;

import com.bg.data.Persion;
import com.bg.repo.PersionRepo;
import com.bg.repo.PersionRepoTemp;
import com.bg.service.PersionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("persionService")
public class PersionServiceImpl implements PersionService {

    @Autowired
    PersionRepo persionRepo;

    @Autowired
    PersionRepoTemp persionRepoTemp;

    @Override
    public void insertPersion(List<Persion> persions) {
        List<Persion> pers = persionRepo.insert(persions);
        pers.forEach(x -> System.out.println(x.getId() + "\t" + x.getName() + "\t" + x.getAge() + "\t" + x.getAddress()));
    }

    @Override
    public void insertBase(Persion persion) {
        persionRepoTemp.insertBase(persion);
    }

    @Override
    public Persion findOne(Map<String, Object> params) {
        return persionRepoTemp.findOne(params);
    }

    @Override
    public List<Persion> findAll(Map<String, Object> params) {
        return persionRepoTemp.findAll(params);
    }

    @Override
    public void update(Map<String, Object> params) {
        persionRepoTemp.update(params);
    }

    @Override
    public void remove(Map<String, Object> params) {
        persionRepoTemp.remove(params);
    }

    @Override
    public List<Persion> getPagePersion(int pageNum, int pageSize) {
        return persionRepoTemp.getPagePersion(pageNum,pageSize);
    }
}
